package com.itheima.controller;

import com.itheima.common.R;
import com.itheima.service.SensitiveVocabularyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * <h1>敏感词接口</h1>
 *
 * @author <a href="515857087@qq.com">叶世铭</a>
 * @since 2022/12/8
 */
@RestController
@RequestMapping("/sensitive_vocabulary")
@Api(tags = "敏感词api")
public class SensitiveVocabularyController {

    @Resource
    private SensitiveVocabularyService sensitiveVocabularyService;

    /**
     * 导入新的敏感词
     *
     * @param file
     * @return
     * @throws IOException
     */
    @ApiOperation(value = "导入新的敏感词")
    @PutMapping("/txtImport")
    public R<String> txtImport(@RequestParam("file") MultipartFile file) throws IOException {
        sensitiveVocabularyService.txtImport(file);
        return R.success("导入成功");
    }
}
